package model.dao.registerOrder;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import log.MyLogger;
import model.service.Person;

public class EmployeeDAOImpl{

	String sql = "" ;
	db.dbconnection dbconnection ;
	Connection myConnection ;
	Statement st ;
	
	public Person getPersonByEmployeeId(int employeeId) {
		Person person = null;
		try {
			myConnection = dbconnection.getConnection();
			Statement st = myConnection.createStatement();
			String sql = "SELECT person_fk from employee WHERE employee = "+employeeId;
			ResultSet resultSet = st.executeQuery(sql);
			int personId = 0;
			
			while(resultSet.next()){
				personId = resultSet.getInt("person_fk");
			}
			
			PersonDAOImpl personDAOImpl = new PersonDAOImpl();
			person = personDAOImpl.getPersonById(personId);
			this.dbconnection.close();
		} catch (Exception e) {
//			MyLogger.Log("EmployeeDAOImpl.getPersonByEmployeeId()", e.getMessage());
		}
		
		return person;
	}

}
